$("#btnSave").click(function() {

    var userName = getQueryString('userName'),
        oldPhone = getQueryString('phone'),
        password = $('#password').val(),
        newPhone = $('#newPhone').val(),
        authCode = $('#authCode').val();

    if (!password) {
        parent.layer.alert('登录密码不能为空！');
        return;
    }
    if (!newPhone) {
        parent.layer.alert('新手机号码不能为空！');
        return;
    } else if (!validator(newPhone, 'mobile')) {
        parent.layer.alert('请输入正确的手机号！', {
            icon: 2
        });
        return;
    }
    if (newPhone == oldPhone) {
        parent.layer.alert('新手机号码不能和原手机号码相同！');
        return;
    }
    if (!authCode) {
        parent.layer.alert('请输入验证码！');
        return;
    }


    parent.layer.confirm('确认修改手机号码？', {
        title: '提示',
        icon: 3
    }, function() {
        $.ajax({
            url: webConfig.webUrl + '/sseUser/updatePhone',
            type: 'POST',
            datatype: 'json',
            data: {
                userName: userName,
                password: password,
                newPhone: newPhone,
                authCode: authCode
            },
            success: function(data) {
                checkResultCode({
                    code: data.code,
                    msg: data.message
                }, '修改手机号码成功', 1, 1);
            }
        });
    });
});

function getCode(val){
        var username = '',//document.getElementById('userName'),
        phone = document.getElementById('newPhone'),
        errorEle = $('.login_alert');
    var countdown=60;
    // if(!username.value){
    //     parent.layer.alert('用户名不能为空！');
    //     username.select();
    //     return;
    // }
    if(!phone.value){
        parent.layer.alert('电话号码不能为空！',function(index){
            phone.select();
            parent.layer.close(index);
        });
        return;
    }else if(!validator(phone.value,'mobile')){
        parent.layer.alert('电话号码格式不正确！',function(index){
            phone.select();
            parent.layer.close(index);
        });
        return;
    }
    val.setAttribute('disabled','disabled');
    var timer = setInterval(function() {
        if (countdown == 0) {
            val.removeAttribute("disabled");
            val.innerHTML="获取验证码";
            countdown = 60;
            clearInterval(timer);
        } else {
            if(countdown == 60-2){
                layer.alert('哈哈哈，其实功能还没有做哟',function(index){
                    val.removeAttribute("disabled");
                    val.innerHTML="获取验证码";
                    layer.close(index);
                });
                window.clearInterval(timer);
            }
            val.setAttribute("disabled", true);
            val.innerHTML= countdown + "s";
            countdown--;
        }
    },1000);
}





function btnBack() {
    parent.layer.closeAll('iframe');
}